<template>
    <div>
        <a-card :title="$t('menuItem.Notice')" style="height: 95vh">
            <a-table
                    size="small"
                :columns="columns"
                :data-source="data"
                :loading="loadTable"
                :rowKey="(record,index)=>{return index}"
                :scroll="{ y:windowHeight-260}"
                :pagination="{
                            pageSize:10,
                            size: 'small',
                            total: data.length,
                             showTotal: (total, range) => {
                                return $t('menuItem.total')+` ${total} `+$t('menuItem.term')
                              },
                          }"
            >
            </a-table>
        </a-card>
    </div>
</template>
<script>

import SendMsg from "../../api/SendMsg";
import {message} from "ant-design-vue";

export default {
    components: {},
    data() {
        return {
            data: [],
            columns: [
              {
                title: this.$t('menuItem.Content'),
                dataIndex: 'content',
                width: 360,
                key: 'content',
                customRender: (text, record, index) => {
                  const content = text.split('\n')
                  return (
                      content.map(item =>{
                        return (<li>{item}</li>)
                        })
                  )
                }
              },
              {
                title: this.$t('menuItem.UpdateTime'),
                dataIndex: 'updateTime',
                width: 100,
                key: 'updateTime',
              }
            ],
            loadTable: false,
            windowHeight: document.documentElement.clientHeight,   //实时屏幕高度
        }
    },
    methods: {
        listAnnounceFunc() {
            var inTrxObj = {
                trxId: "sysNotice",
                actionFlg: 'QS'
            };
            SendMsg.sendPostTrx(inTrxObj).then(res => {
                let outTrx = res.data;
                console.log(outTrx, '查询table数据')
                if ('0000000' === outTrx.rtnCode) {
                    this.data = outTrx.oaryA.map((item, index) => {
                      console.log(outTrx.oaryA[index].content)
                          // .content = outTrx.oaryA[index].content.replace(/\\r\\n/g, '<br/>')
                        item.key = (index + 1);
                        return item;
                    });
                }
            });

        },
    },
    mounted() {
        this.listAnnounceFunc();
        window.onresize = () => {
            return (() => {
                window.fullHeight = document.documentElement.clientHeight;
                this.windowHeight = window.fullHeight;
            })();
        };
    }
}
</script>
